﻿package com.toncen.samepms.system.dao;

import com.toncen.samepms.common.AbstractDao;
import com.toncen.samepms.system.domain.Configuration;

/**
 * 描述：系统配置项表SYSTEM_CONFIGURATION的dao文件
 * 
 * @author tch
 */
public class ConfigurationDao extends AbstractDao<Configuration> {

	public ConfigurationDao() {
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.comit.common.db.BaseDao#initialize()
	 */
	@Override
	protected void initialize() {
		setStatementPrefix("Configuration");
		setStatementDivision(".");
	}

	/**
	 * @param name
	 * @return
	 * @throws Exception
	 */
	public Configuration getByName(String name) throws Exception {
		return (Configuration) getSqlMap().queryForObject(getStatement("getByName"), name);
	}

	/**
	 * @param name
	 * @return
	 * @throws Exception
	 */
	public String getValueByName(String name) throws Exception {
		Configuration c = getByName(name);
		if (c == null) {
			throw new Exception("系统配置【" + name + "】不存在，请与系统管理员联系！");
		}
		return c.getValue();
	}

	/**
	 * @param domain
	 * @return
	 * @throws Exception
	 */
	public int updateNocache(Configuration domain) throws Exception {
		return getSqlMap().update(getStatement("updateNocache"), domain);
	}
}
